class Redprint:
    def __init__(self, name):
        self.name = name
        self.mound = []

    def route(self, rule, **options):
        def decorator(f):  # f是指被装饰的函数
            self.mound.append((f, rule, options))
            return f

        return decorator

    def register(self, bp, url_prefix=None):
        '''
        :param bp: 蓝图
        :param url_prefix:前缀地址
        '''
        if url_prefix==None:
            url_prefix='/'+self.name
        for f, rule, options in self.mound:
            # 字典 pop() 方法删除字典给定键 key 及对应的值，返回值为被删除的值
            # ,第二个参数为找不到指定key时返回的默认值
            endpoint = self.name+'+'+options.pop('endpoint', f.__name__)
            bp.add_url_rule(url_prefix + rule, endpoint, f, **options)
